<template>
  <div class="app-container">
    <el-row>
      <el-col :span="22">
        <el-form ref="querySeat" :model="searchData" :inline="true" label-width="100px">
          <el-form-item label="演出场地名称">
            <el-select
              v-model="searchData.yardId"
              size="small"
              filterable
              placeholder="请选择演出场地名称"
              clearable
              @change="changeYardName"
            >
              <el-option
                v-for="item in yardOptions"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              >
                {{ item.name }}
              </el-option>
            </el-select>
          </el-form-item>
          <!--            <el-form-item>-->
          <!--              <el-button type="primary" icon="el-icon-search" size="mini" @cliclk="querySeat">搜索</el-button>-->
          <!--              <el-button icon="el-icon-refresh" size="mini" @click="restart">重置</el-button>-->
          <!--            </el-form-item>-->
        </el-form>
      </el-col>
      <el-col :span="2" type="flex" justify="end">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="small"
          @click="addSeat"
        >新增座位</el-button>
      </el-col>
    </el-row>
    <div class="seats-container">
      <div class="card-container">
        <div class="card-item"  v-for="seat in seatData" :key="seat.id">
          <div class="card-item-content">
            <div class="card-page" @click="seatEditl(seat.id)">
              <div style="padding:17px 17px 0;">
                <img src="./img/seat.png" style="width:168px;height:98px;" class="image">
              </div>
              <div class="card-page-content">
                <span class="card-title">{{seat.seatName}}</span>
                <div class="card-content">
                  <p>演出场地：{{seat.yardName}}</p>
                  <p style="margin-top:10px">座位数：<span>{{seat.seatCount}}</span>座</p>
                  <p style="margin-top:10px">创建时间：{{parseTime(seat.createTime)}}</p>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <el-row
      type="flex"
      justify="center"
      class="pagination"
    >
      <el-pagination
        background
        :current-page="seatPage.currentPage"
        :page-sizes="[10, 20, 30]"
        :page-size="seatPage.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="seatPage.totalElements"
        @size-change="userSize"
        @current-change="pgChge"
      />
    </el-row>
  </div>
</template>
<script>
  import {getDataForSP, writePageInfo} from "@/utils/webUtils";

  export default {
    name:'seatList',
    data(){
      return{
        yardOptions:[],
        searchData: { yardId: '' },
        seatData:[],
        seatPage: {
          pageSize: 10, // 每页显示条目个数
          currentPage: 1, // 当前页数
          totalElements: 0,
          searchData: {
            yardId: ''
          }
        },
        userSchOn: '',
      }
    },
    created() {
      this.querySeat(this.searchData)
      this.queryYard()
    },
    methods:{
      seatEditl(val){
        this.$router.push({
          path:'/editSeat',
          query:{id:val}
        })
      },
      // 演出场地查询
      queryYard() {
        this.axios
          .request({
            method: 'get',
            url: './tck/seat/listStudio',
            params: {}
          })
          .then(response => {
            this.yardOptions = response.data.data
          })
          .catch(error => {
            console.log(error)
          })
      },
      // 查询
      changeYardName() {
        this.querySeat(this.searchData)
      },
      // 获取所有数据
      querySeat(param) {
        // 演出场地名称
        this.seatPage.searchData.yardId = param.yardId
        this.axios.request({
          method: 'get',
          url: './tck/seat/listSeat',
          params: getDataForSP(this.seatPage)
        }).then(response => {
          this.seatData = response.data.data
          writePageInfo(this.seatPage, response.data)
        }).catch(error => {
          console.log(error)
        })
          .catch(error => {
            console.log(error)
          })
      },
      addSeat(){
        this.$router.push('/addSeat');
      },
      // 列表分页
      userSize: function(pageSize) {
        this.seatPage.pageSize = pageSize
        if (this.seatPage.currentPage === 1) {
          if (this.userSchOn !== '') {
            // this.userSearch();
          } else {
            this.querySeat(this.searchData)
          }
        }
        this.seatPage.currentPage = 1
      },
      pgChge(currentPage) {
        this.seatPage.currentPage = currentPage
        this.querySeat(this.searchData)
      }
    }
  }
</script>
<style lang="scss" scoped rel="stylesheet/scss">
  .app-main{
    background-color: #F7F8F9;
    overflow: auto;
  }
  .app-container{
    min-width: 1240px;
    position: relative;

    min-height: 100%;
    display: block;
    overflow: auto;
    font-family: 'Microsoft YaHei';
  }
  .seats-container{
    // width: 1200px;
    padding: 16px 0;
    .el-col--4,.el-col-md-4-8 {
      width: 20%;
      margin-bottom: 74px;

    }
  }
  .card-container{
    // align-content: flex-start;
    display: flex;
    flex-wrap: wrap;
    // align-content:space-between;
    margin-left: -16px;
  }
  .card-item{
    margin-left: 16px;
    // &:first-of-type{
    //     margin-left: 0;
    // }
  }
  .card-item-content{
    height: 274px;
    margin: 0 0 16px 0;
  }
  .card-page{
    width: 210px;
    height: 234px;
    background: #fff;
    border-bottom-right-radius: 40px;
    position: relative;
    filter: drop-shadow(0px 0px 15px #bbb);
    cursor: pointer;
  }
  .card-page-content{
    width: 170px;
    height: 159px;
    padding: 12px 0 0 17px ;
    background: #fff;
    position: absolute;
    bottom: -40px;
    /* border:1px solid #f00; */
    /* padding: 50px 0 0 60px; */
    border-bottom-right-radius: 40px;
    box-sizing: border-box;
  }
  .card-title{
    font-size: 16px;
    height: 21px;
    line-height: 21px;
    font-weight:400;
    color: #171717;
  }
  .card-content{
    margin-top: 12px;
    p{
      font-size: 12px;
      height: 16px;
      line-height: 16px;
      font-weight: 400;
      color: #636363;
      margin: 0;
    }
  }
</style>
